package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.DeviceUse;
import com.sailfish.springbootdemo.service.db1.DeviceUseService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/deviceUse")
@CrossOrigin
public class DeviceUseController {

    @Autowired
    private DeviceUseService deviceUseService;

    @PostMapping("/getAllDeviceUse")
    public Result getAllDeviceUse(Integer status) {
        try {
            if (status == null || "".equals(status.toString())) {
                return ResultUtil.error(500, "缺少参数status", "Miss Param status", null);
            }
            return ResultUtil.success(deviceUseService.getAllDeviceUse(status));
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }
}
